package com.xiaoxu.yihaoShop.ProvenceJob;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class ProvenceApp {

    public static void main(String[] args) throws Exception{

        Configuration configuration = new Configuration();

        FileSystem fileSystem = FileSystem.get(configuration);
        Path outPutPath = new Path("data/output/provence/");
        if (fileSystem.exists(outPutPath)){
            fileSystem.delete(outPutPath,true);
            System.out.println("输出结果已被删除");
        }



        Job job = Job.getInstance(configuration);

        job.setJarByClass(ProvenceApp.class);

        job.setMapperClass(ProvenceMapper.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);

        job.setReducerClass(ProvenceReduce.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(LongWritable.class);


        FileInputFormat.setInputPaths(job,new Path("data/output/etl/part-r-00000"));
        FileOutputFormat.setOutputPath(job,outPutPath);

        job.waitForCompletion(true);



    }
}
